<template>
  <div>
    <el-form size="mini" label-width="70px">
      <el-form-item label="标题">
        <el-input v-model="title" clearable style="width:60%;"></el-input>
      </el-form-item>
      <el-form-item>
        <vue-ueditor-wrap
          v-model="msg"
          :config="myConfig"
          style="width:90%;"
        ></vue-ueditor-wrap>
      </el-form-item>
      <el-form-item>
        <el-button type="success" @click="save">
          保存
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import VueUeditorWrap from "vue-ueditor-wrap";
import http from "@/request/http";
import QS from "qs";
import axios from "axios";
export default {
  data() {
    return {
      title: "",
      msg: "",
      myConfig: {
        UEDITOR_HOME_URL: "/static/UEditor/"
        // serverUrl: "http://localhost:8089/ueditor/ue"
      }
    };
  },
  components: {
    VueUeditorWrap
  },
  methods: {
    save() {
      console.log(this.title);
      console.log(this.msg);
      let data = {
        construct_qrcode_title: this.title,
        construct_qrcode_content: this.msg,
        user_id: sessionStorage.getItem("userid")
      };
      axios
        .post(`${http.middle_url}saveConstructQr`, data, {
          transformRequest: [
            function(data) {
              data = QS.stringify(data);
              return data;
            }
          ]
        })
        .then(res => {
          this.$message.success(res.data.msg);
          this.$emit("close");
        });
    }
  }
};
</script>

<style lang="scss" scoped></style>
